package ar.com.globallogic.promomr.domain;

public class AgeContentFilter extends ContentFilter {

	private Integer minAge;
	private Integer maxAge;
	
	public AgeContentFilter(Integer minAge, Integer maxAge){
		this.minAge = minAge;
		this.maxAge = maxAge;
	}
	
	@Override
	public boolean passes(User user) {
		if(isUserUnderMinAge(user) || isUserOverMaxAge(user)){
			return false;
		}
		return this.getNext().passes(user);
	}
	
	protected boolean isUserUnderMinAge(User user) {
		return user.isUnderAge(minAge);
	}

	protected boolean isUserOverMaxAge(User user) {
		return !user.isUnderAge(maxAge);
	}

}
